package feeinterface.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ulwx.database.DataBaseSet;
import com.ulwx.database.RowMapper;
import com.ulwx.tool.DbUtils;


import feeinterface.modeldb.ChannelPhoneOverDayFee;



public class ChannelPhoneOverDayFeeDao {

	private static Logger log = Logger.getLogger(ChannelPhoneOverDayFeeDao.class); // 跟类名一样
	
	public static void Insert(ChannelPhoneOverDayFee bi) throws Exception{
		
		String sql="insert into ChannelPhoneOverDayFee(Phone,ChannelID,UpdateTime)" +
				"values(?,?,?)";
		Map<Integer,Object> map=new HashMap<Integer,Object>();
		map.put(1, bi.getPhone());
		map.put(2, bi.getChannelID());
		map.put(3, bi.getUpdateTime());

		DbUtils.executeBindUpdate(null,sql, map);
		
	}
	
	public static List<Integer> getCantUseChannels(String phone){
		String sql="select ChannelID from  ChannelPhoneOverDayFee where Phone=? and " +
				" UpdateTime>=CURDATE() ";
		Map<Integer,Object> map=new HashMap<Integer,Object>();
		map.put(1, phone);
		try{
			List<Integer> list=DbUtils.doQueryObject(null, sql, map, new  RowMapper<Integer>(){

			
			public Integer mapRow(DataBaseSet rs) throws Exception {
				// TODO Auto-generated method stub
				return rs.getInt("ChannelID");
				
			}
			
		});
			
			return list;
		}catch(Exception e){
			log.error("",e);
		}
		return new ArrayList<Integer>();
		
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
